<?php

namespace services\models;

class rule {

    private $_db;
    private $_cache;

    public function __construct($db, $cache) {
        $this->_db = $db;
        $this->_cache = $cache;
    }

    public function get_all() {

        if ($this->_cache->cache('all_rules')) {
            return $this->_cache->cache('all_rules');
        } else {
            $rules = $this->_db->select('rules');
            $exce = $this->_db->getPDOException();
            if ($exce) {
                throw $exce;
            }

            $this->_cache->cache('all_rules', $rules);
            return $rules;
        }
    }

}

?>
